# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=hyperfine
pkgver=1.18.0
pkgrel=0
pkgdesc="Command-line benchmarking tool"
url="https://github.com/sharkdp/hyperfine"
# s390x, loongarch64: nix statfs broken with musl
arch="all !s390x !loongarch64"
license="Apache-2.0 AND MIT"
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="https://github.com/sharkdp/hyperfine/archive/v$pkgver/hyperfine-$pkgver.tar.gz"

export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test all --frozen
}

package() {
	install -Dm755 target/release/hyperfine \
		"$pkgdir"/usr/bin/hyperfine
	install -Dm644 doc/hyperfine.1 \
		"$pkgdir"/usr/share/man/man1/hyperfine.1

	install -Dm644 target/release/build/hyperfine-*/out/hyperfine.bash \
		"$pkgdir/usr/share/bash-completion/completions/hyperfine"
	install -Dm644 target/release/build/hyperfine-*/out/_hyperfine \
		"$pkgdir/usr/share/zsh/site-functions/_hyperfine"
	install -Dm644 target/release/build/hyperfine-*/out/hyperfine.fish \
		"$pkgdir/usr/share/fish/vendor_completions.d/hyperfine.fish"
}

sha512sums="
9792679b55efa224f31aa789780db36aa2f036114eec704703d46418c777fa512f28a3910928d894f3abb02c24dbd84d13791824eaa4c53a876c69e5d6f1ede4  hyperfine-1.18.0.tar.gz
"
